import {
  wxRequest
} from '../../../utils/server.js';
const _wxRequest = new wxRequest();
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    
  },

  formSubmit: function(e) {
    var formdata = e.detail.value;
    if (formdata.groupName == '') {
      wx.showToast({
        icon: 'none',
        title: '商品组名称不能为空',
      })
      return
    }

    if (formdata.identity == '') {
      wx.showToast({
        icon: 'none',
        title: '组别名称不能为空',
      })
      return
    }


    _wxRequest.wxTonkenAjax({
      url: app.globalData.apiUrl + '/gds/protected/comm/beanCrud/gds.GoodsGroupVO/create',
      method: 'POST',
      data: formdata
    }, (res) => {
      console.log(res)
      
        wx.showToast({
          title: '发布成功',
        })
        setTimeout(() => {
          wx.redirectTo({
            url: '/pages/publish/index',
          })
        }, 1500) 
    }) 
  },

//返回
  goback: function () {
    wx.navigateBack({})
  }

})